program e;

{$APPTYPE CONSOLE}

var
  c, i, n, m, mi, mc: Integer;
  ms: char;
  rs: String;
  equals: Boolean;
  a: array[1..1000000] of Integer;
function i2s(i: Integer): String;
begin
  Str(i, Result);
end;

begin
  readln(n, m);
  for i := 1 to m do
    a[i] := 0;
  mc := 0;
  ms := '+';
  equals := False;
  rs := '';
  for i := 1 to n do
  begin
    read(c);
    Inc(a[c]);
    if (mc = 0) then begin
      mi := c;
      mc := 1;
    end
    else
      if a[c] > mc then begin
        mi := c;
        equals := False;
        mc := a[c]
      end
      else
      if a[c] = mc then
        equals := True;
    if equals then
      rs := rs + ms + ' '
    else
      rs := rs + i2s(mi) + ' ';
  end;
  writeln(rs);
  readln;
  readln;
end.